package im.engure.common.protocol;

import im.engure.common.protocol.impl.DubboProtocol;
import im.engure.common.protocol.impl.HttpProtocol;

public class ProtocolFactory {

    private static final String DEFAULT_PROTOCOL = "http";

    public static Protocol getProtocol() {

        String protocolName = System.getProperty("protocolName");
        if (protocolName == null || protocolName.length() < 1) {
            protocolName = DEFAULT_PROTOCOL;
        }

        switch (protocolName) {
            case "http":
                return new HttpProtocol();
            case "dubbo":
                return new DubboProtocol();
        }

        return new HttpProtocol();
    }
}
